const rewiredServer = require('@knx-engr/rewired-server');
const rewiredMicro = require('@knx-engr/rewired-micro');
const rewiredAliases = require('@knx-engr/rewired-aliases');
const rewiredLess = require('@knx-engr/rewired-less');
const rewiredBabel = require('@knx-engr/rewired-babel');
const path = require('path');

module.exports = (config, env) => {
  config = rewiredServer(config, env);
  //You can rewired the configuration here.
  config = rewiredAliases({
    '@root': path.resolve(__dirname, './src'),
    '@pages': path.resolve(__dirname, './src/pages'),
    '@common': path.resolve(__dirname, './src/common'),
    '@components': path.resolve(__dirname, './src/components')
  })(config, env);

  config = rewiredLess.withOptions({
    options: {
      modifyVars: {
        'primary-color': '#3397D5',
        'link-color': '#3397D5'
      },
      javascriptEnabled: true
    }
  })(config, env);

  config = rewiredBabel({
    plugins: [[require.resolve('babel-plugin-import'), {
      'libraryName': 'antd',
      'style': true
    }]]
  })(config, env);

  config = rewiredMicro(config, env);
  return config;
};

